package com.chatbot.repository;

import com.chatbot.entity.CharacterConversation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CharacterConversationRepository extends JpaRepository<CharacterConversation, Long> {
    // 根据用户ID查找所有对话
    List<CharacterConversation> findByUser_Id(Long userId);
    
    // 根据用户ID分页查找对话
    Page<CharacterConversation> findByUser_Id(Long userId, Pageable pageable);
    
    // 根据用户ID和角色ID查找对话
    List<CharacterConversation> findByUser_IdAndCharacter_CharacterId(Long userId, Long characterId);
    
    // 根据用户ID和对话ID查找对话
    CharacterConversation findByUser_IdAndCharacterConversationId(Long userId, Long conversationId);
    
    // 删除指定用户的指定对话
    void deleteByUser_IdAndCharacterConversationId(Long userId, Long conversationId);

    Page<CharacterConversation> findByUser_IdAndCharacter_CharacterId(Long userId, Long characterId, Pageable pageable);
} 